const path = require("path");
//复制文件
const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    mode: "production", //development：开发环境 production：生产环境（js会自动压缩代码）
    entry: "./src/app.js",
    output: {
        clean: true,//清除之前的打包文件
        libraryTarget: "commonjs",
        filename: "index.js",
        path: path.resolve(__dirname, "./dist"),
    },
    target: "node",
    plugins: [
        new CopyWebpackPlugin({
            patterns: [
                { from: "public", to: "public" },
                { from: "package.json", to: "package.json" }
            ],
        })
    ],

    externals: [/^(?!\.|\/).+/i],
};
